<template>
  <h2>当前求和为：{{ sum }}</h2>
  <button @click="changeSum">点我加一</button>
</template>

<script>
import { reactive, ref, watch, watchEffect, onBeforeMount } from "vue";
export default {
  name: "Demo",
  setup() {
    let sum = ref(0);
    function changeSum() {
      sum.value++;
    }

    // 组合式API形式生命周期钩子
    onBeforeMount(() => {
      console.log("onBeforeMount");
    });

    return {
      sum,
      changeSum,
    };
  },
  //#region
  /*  beforeCreate() {
    console.log("beforeCreate");
  },
  created() {
    console.log("created");
  },
  beforeMount() {
    console.log("beforeMount");
  },
  mounted() {
    console.log("mounted");
  },
  beforeUpdate() {
    console.log("beforeUpdate");
  },
  updated() {
    console.log("updated");
  },
  beforeUnmount() {
    console.log("beforeUnmount");
  },
  unmounted() {
    console.log("unmounted");
  }, */
  //#endregion
};
</script>

<style>
</style>
